/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"barge/app"
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

// tidyCmd represents the version command
var tidyCmd = &cobra.Command{
	Use:   "tidy",
	Short: "整理配置信息",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		m, err := app.NewConfigManager(viper.GetString("configPath"))
		if err != nil {
			log.Err(err).Str("path", viper.GetString("configPath")).Send()
			return
		}
		err = m.Save()
		if err != nil {
			log.Err(err).Str("path", viper.GetString("configPath")).Send()
			return
		}
	},
}

func init() {
	rootCmd.AddCommand(tidyCmd)
}
